<!DOCTYPE html>
<html>
	<head>
		<title>角色组管理</title>
		<!-- css -->
		<link href="../css/themes/base/easyui.css" rel="stylesheet" />
		<link href="../css/themes/skin-redlight.css" rel="stylesheet" />
		<link href="../css/site.css" rel="stylesheet" />
		<link href="../css/fontawesome/css/font-awesome.min.css" rel="stylesheet" />
		<style>
			.over{top:0;left:0;z-index:9999999;width:100%;height:100%;background-color:#f5f5f5;opacity:.5}
			.layout,.over{position:absolute;display:none}
			.layout{top:40%;left:40%;z-index:100000000;width:20%;height:20%;text-align:center}
			</style>

		<script src="../js/utils/jquery.min.js" type="text/javascript"></script>
		<script src="../js/utils/baseUrl.js"></script>
		<script src="../js/easyui/jquery.easyui.min.js" type="text/javascript"></script>
		<script src="../js/easyui/easyui-lang-zh-CN.js" type="text/javascript"></script>
		<script src="../js/easyui/jquery.easyui.plus.js"></script>
		<script src="../js/utils/common.js"></script>
		<script src="../js/utils/jquery.form.js"></script>


	</head>
	<body>
		<div style="padding:4px 5px 0px 5px;">

			<div class="mvctool">
				<input id="txtQuery" type="text" class="searchText" />
				<a id="btnQuery" class="btn btn-default"><span class="fa fa-search"></span>&nbsp;查询</a>
				<a id="btnCreate" class="btn btn-success"><span class="fa fa-plus"></span>&nbsp;创建</a>
				<a id="btnEdit" class="btn btn-warning"><span class="fa fa-pencil"></span>&nbsp;修改</a>
				<a id="btnDetails" class="btn btn-default"><span class="fa fa-list"></span>&nbsp;详细</a>
				<a id="btnDelete" class="btn btn-danger"><span class="fa fa-trash"></span>&nbsp;删除</a>
				<a id="btnAllot" class="btn btn-default"><span class="fa fa-user-plus"></span>&nbsp;分配用户</a>
			</div>
			<div id="modalwindow" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
			<table id="List"></table>
		</div>
		<div id="over" class="over"></div>
		<div id="layout" class="layout"><img src="../img/loading.gif" /></div>
		<div id="fullSetContent"></div>
		<script type="text/javascript">
			$(function() {
				$('#List').datagrid({
					url: baseUrl + '/zh-CN/SysRole/GetList',
					width: SetGridWidthSub(10),
					methord: 'post',
					height: SetGridHeightSub(45),
					fitColumns: true,
					sortName: 'CreateTime',
					sortOrder: 'desc',
					idField: 'Id',
					pageSize: 15,
					pageList: [15, 20, 30, 40, 50],
					pagination: true,
					striped: true, //奇偶行是否区分
					singleSelect: true, //单选模式
					//rownumbers: true,//行号
					onLoadSuccess: function(data) {
						$(".datagrid-row td div").addClass("exceed");

					},
					columns: [
						[{
								field: 'Id',
								title: 'ID',
								width: 80,
								hidden: true
							},
							{
								field: 'Name',
								title: '角色名称',
								width: 80,
								sortable: true
							},
							{
								field: 'Description',
								title: '备注',
								width: 80,
								sortable: true
							},
							{
								field: 'CreateTime',
								title: '创建时间',
								width: 80,
								sortable: true
							},
							{
								field: 'CreatePerson',
								title: '创建人',
								width: 80,
								sortable: true
							},
							{
								field: 'UserName',
								title: '属下管理员',
								width: 80,
								sortable: true
							}
						]
					]
				});
			});
			//ifram 返回
			function frameReturnByClose() {
				$("#modalwindow").window('close');
			}

			function frameReturnByReload(flag) {
				if (flag)
					$("#List").datagrid('load');
				else
					$("#List").datagrid('reload');
			}

			function frameReturnByMes(mes) {
				$.messageBox5s(Lang.Tip, mes);
			}
			$(function() {
				$("#btnCreate").click(function() {
					$("#modalwindow").html(
						"<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/SysRole/Create'></iframe>");
					$("#modalwindow").window({
						title: Lang.Create,
						width: 700,
						height: 400,
						iconCls: 'fa fa-plus'
					}).window('open');
				});
				$("#btnEdit").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {
						$("#modalwindow").html("<iframe width='100%' height='100%'  frameborder='0' src='/SysRole/Edit?id=" + row.Id +
							"&Ieguid=" + GetGuid() + "'></iframe>");
						$("#modalwindow").window({
							title: '修改',
							width: 700,
							height: 430,
							iconCls: 'fa fa-pencil'
						}).window('open');
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$("#btnDetails").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {
						$("#modalwindow").html(
							"<iframe width='100%' height='100%' scrolling='no' frameborder='0' src='/SysRole/Details?id=" + row.Id +
							"&Ieguid=" + GetGuid() + "'></iframe>");
						$("#modalwindow").window({
							title: '详细',
							width: 500,
							height: 300,
							iconCls: 'fa fa-list'
						}).window('open');
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$("#btnQuery").click(function() {
					var queryStr = $("#txtQuery").val();
					if (queryStr == null) {
						queryStr = "%";
					}
					$('#List').datagrid({
						url: '/zh-CN/SysRole/GetList?queryStr=' + encodeURI(queryStr)
					});

				});
				$("#btnDelete").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {
						$.messager.confirm(index_lang_tip, '你要删除所选择的记录吗？', function(r) {
							if (r) {
								$.post("/zh-CN/SysRole/Delete?id=" + row.Id, function(data) {
									if (data.type == 1)
										$("#List").datagrid('load');
									$.messageBox5s(Lang.Tip, data.message);
								}, "json");

							}
						});
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$("#btnAllot").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {
						$("#modalwindow").html(
							"<iframe width='100%' height='100%' scrolling='no' frameborder='0' src='/SysRole/GetUserByRole?roleId=" +
							row.Id + "&Ieguid=" + GetGuid() + "'></iframe>");
						$("#modalwindow").window({
							title: '分配用户',
							width: 720,
							height: 400,
							iconCls: 'fa fa-pencil'
						}).window('open');
					} else {
						$.messageBox5s(Lang.Tip, '请选择一个需要分配用户的角色');
					}
				});
			});
			<!--自动GRID 从第一次加载与重置窗体大小时候发生的事件:分部视图，当只有一个Grid时且ID为List-->
			$(function() {
				$(window).resize(function() {
					$('#List').datagrid('resize', {

					}).datagrid('resize', {
						width: SetGridWidthSub(10),
						height: SetGridHeightSub(45)
					});
				});

			});

			$(function() {
				if (isExitsFunction(window.parent.fullSetButtonOut)) {
					$("#fullSetContent").html(window.parent.fullSetButtonOut());
					$("#fullSetButton").click(function() {
						if ($(this).attr("class") == "fa fa-expand") {
							$(this).removeClass("fa-expand").addClass("fa-compress");
						} else {
							$(this).removeClass("fa-compress").addClass("fa-expand");
						}
						window.parent.fullSet();
					});
				}
			});
		</script>
	</body>
</html>
